/*===============================================
Copyright (c): Technology Co.,Ltd. ALL rights reserved. 
                                                                 
  Create by: Lin
      Email:
       Date:
   Filename:
Description:
    Version:
Last Change:
                                                                 
=======================================*/
                                                                 
`ifndef MII_SEQ_SV
`define MII_SEQ_SV

`include "mii_seq_item.sv"

class mii_base_seq extends uvm_sequence #(mii_seq_item);
	`uvm_object_utils(mii_base_seq)

	extern function new(string name = "mii_base_seq");
	extern virtual task pre_body();
	extern virtual task post_body();

endclass

function mii_base_seq::new(string name = "mii_base_seq");
	super.new(name);
	`uvm_info("TRACE", $sformatf("%m"), UVM_HIGH);
endfunction

task mii_base_seq::pre_body();
	`uvm_info(get_type_name(), "start raise_objection", UVM_HIGH);
//	starting_phase = get_starting_phase();
	if (starting_phase != null) begin
		uvm_objection objection = starting_phase.get_objection();
		objection.set_drain_time(this, 3us);
		starting_phase.raise_objection(this, {"Running sequence'", get_full_name(), "'"});
	end
endtask

task mii_base_seq::post_body();
//	starting_phase = get_starting_phase();
	if (starting_phase != null) begin
		starting_phase.drop_objection(this, {"Completed sequence '", get_full_name(), "'"});
	end
endtask



class mii_seq extends mii_base_seq;
	`uvm_object_utils(mii_seq)

	extern function new(string name = "mii_seq");
	extern task body();
endclass

function mii_seq::new(string name = "mii_seq");
	super.new(name);
	`uvm_info("TRACE", $sformatf("%m"), UVM_HIGH);
endfunction

task mii_seq::body();
	`uvm_info(get_type_name(), "default sequence starting", UVM_HIGH)
	for (int i = 0; i < 20; i++) begin
		req = mii_seq_item::type_id::create("req");
		start_item(req);
		if (!req.randomize())
			`uvm_error(get_type_name(), "Failed to randomize transaction")
		finish_item(req);
		`uvm_info(get_type_name(), "default sequence completed", UVM_HIGH)
	end
endtask

class write_read_sequence extends uvm_sequence #(mii_seq_item);
	
endclass

`endif
